﻿using System;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace Zxb.DayWork.Logic
{
    public class DB
    {
        private static object lockObj = new object();
        private static Database zxbReader;
        private static Database zxbWriter;
        private static Database taskreader;
        private static Database taskwriter;
        private static Database estateReaderNorth;
        private static Database estateReaderSouth;
        private static Database dataCenter;
        private static Database home_logAdmin;
        private static Database local;

        private static Database homeReader;
        private static Database homeWriter;

        private static Database jiaTXHitsReader;
      

        public static Database ZxbReader
        {
            get
            {
                if (zxbReader == null)
                {
                    lock (lockObj)
                    {
                        if (zxbReader == null)
                        {
                            zxbReader = DatabaseFactory.CreateDatabase("ZxbReader");
                        }
                    }
                }
                return zxbReader;
            }
        }

        public static Database ZxbWriter
        {
            get
            {
                if (zxbWriter == null)
                {
                    lock (lockObj)
                    {
                        if (zxbWriter == null)
                        {
                            zxbWriter = DatabaseFactory.CreateDatabase("ZxbWriter");
                        }
                    }
                }
                return zxbWriter;
            }
        }

        public static Database TaskReader
        {
            get
            {
                if (taskreader == null)
                {
                    lock (lockObj)
                    {
                        if (taskreader == null)
                        {
                            taskreader = DatabaseFactory.CreateDatabase("TaskReader");
                        }
                    }
                }
                return taskreader;
            }
        }

        public static Database TaskWriter
        {
            get
            {
                if (taskwriter == null)
                {
                    lock (lockObj)
                    {
                        if (taskwriter == null)
                        {
                            taskwriter = DatabaseFactory.CreateDatabase("TaskWriter");
                        }
                    }
                }
                return taskwriter;
            }
        }

        public static Database EstateReaderNorth
        {
            get
            {
                if (estateReaderNorth == null)
                {
                    lock (lockObj)
                    {
                        if (estateReaderNorth == null)
                        {
                            estateReaderNorth = DatabaseFactory.CreateDatabase("EstateReaderNorth");
                        }
                    }
                }
                return estateReaderNorth;
            }
        }

        public static Database EstateReaderSouth
        {
            get
            {
                if (estateReaderSouth == null)
                {
                    lock (lockObj)
                    {
                        if (estateReaderSouth == null)
                        {
                            estateReaderSouth = DatabaseFactory.CreateDatabase("EstateReaderSouth");
                        }
                    }
                }
                return estateReaderSouth;
            }
        }

        public static Database DataCenter
        {
            get
            {
                if (dataCenter == null)
                {
                    lock (lockObj)
                    {
                        if (dataCenter == null)
                        {
                            dataCenter = DatabaseFactory.CreateDatabase("DataCenter");
                        }
                    }
                }
                return dataCenter;
            }
        }

        public static Database Home_logAdmin
        {
            get
            {
                if (home_logAdmin == null)
                {
                    lock (lockObj)
                    {
                        if (home_logAdmin == null)
                        {
                            home_logAdmin = DatabaseFactory.CreateDatabase("home_logAdmin");
                        }
                    }
                }
                return home_logAdmin;
            }
        }

        public static Database Local
        {
            get
            {
                if (local == null)
                {
                    lock (lockObj)
                    {
                        if (local == null)
                        {
                            local = DatabaseFactory.CreateDatabase("local");
                        }
                    }
                }
                return local;
            }
        }
        /// <summary>
        /// 建材读库
        /// </summary>
        public static Database HomeReader
        {
            get
            {
                if (homeReader == null)
                {
                    lock (lockObj)
                    {
                        if (homeReader == null)
                        {
                            homeReader = DatabaseFactory.CreateDatabase("HomeReader");
                        }
                    }
                }
                return homeReader; 
            }
        }
        /// <summary>
        /// 建材写库
        /// </summary>
        public static Database HomeWriter
        {
            get
            {
                if (homeWriter == null)
                {
                    lock (lockObj)
                    {
                        if (homeWriter == null)
                        {
                            homeWriter = DatabaseFactory.CreateDatabase("HomeWriter");
                        }
                    }
                }
                return homeWriter;
            }
        }
        /// <summary>
        /// 点击量读库
        /// </summary>
        public static Database JiaTXHitsReader
        {
            get
            {
                if (jiaTXHitsReader == null)
                {
                    lock (lockObj)
                    {
                        if (jiaTXHitsReader == null)
                        {
                            jiaTXHitsReader = DatabaseFactory.CreateDatabase("JiaTXHitsReader");
                        }
                    }
                }
                return jiaTXHitsReader;
            }
        }

 
    }
}
